import http from "./index.js";

export const ecAPI = {
  getEcData() {
    return http.get("/ec");
  },
};

export const ocr = {
  getOcrData(file) {
    const formData = new FormData(); // 创建表单数据对象
    formData.append("file", file); // 添加文件字段（字段名需与后端一致）
    return http.post("/ocr", formData, {
      headers: {
        "Content-Type": "multipart/form-data", // 必须设置请求头
      },
    });
  },
};

export const registerAPI = {
  register(userData) {
    return http.post("/register", userData);
  },
};

export const loginAPI = {
  login(userData) {
    return http.post("/login", userData);
  },
};

export const handlerAPI = {
  handler(passage, content_type) {
    return http.post("/handler", {
      passage: passage,
      content_type: content_type,
    });
  },
};
